
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>Introduction to atomman: system_model conversions &#8212; atomman 1.4.0 documentation</title>
    <link rel="stylesheet" href="../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
    <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Introduction to atomman: POSCAR conversions" href="1.4.2._POSCAR_conversions.html" />
    <link rel="prev" title="Introduction to atomman: Load and dump conversions" href="1.4._Load_and_dump_conversions.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="1.4.2._POSCAR_conversions.html" title="Introduction to atomman: POSCAR conversions"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="1.4._Load_and_dump_conversions.html" title="Introduction to atomman: Load and dump conversions"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">atomman 1.4.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Tutorials</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  
<style>
/* CSS for nbsphinx extension */

/* remove conflicting styling from Sphinx themes */
div.nbinput.container div.prompt *,
div.nboutput.container div.prompt *,
div.nbinput.container div.input_area pre,
div.nboutput.container div.output_area pre,
div.nbinput.container div.input_area .highlight,
div.nboutput.container div.output_area .highlight {
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

div.nbinput.container > div[class*=highlight],
div.nboutput.container > div[class*=highlight] {
    margin: 0;
}

div.nbinput.container div.prompt *,
div.nboutput.container div.prompt * {
    background: none;
}

div.nboutput.container div.output_area .highlight,
div.nboutput.container div.output_area pre {
    background: unset;
}

div.nboutput.container div.output_area div.highlight {
    color: unset;  /* override Pygments text color */
}

/* avoid gaps between output lines */
div.nboutput.container div[class*=highlight] pre {
    line-height: normal;
}

/* input/output containers */
div.nbinput.container,
div.nboutput.container {
    display: -webkit-flex;
    display: flex;
    align-items: flex-start;
    margin: 0;
    width: 100%;
}
@media (max-width: 540px) {
    div.nbinput.container,
    div.nboutput.container {
        flex-direction: column;
    }
}

/* input container */
div.nbinput.container {
    padding-top: 5px;
}

/* last container */
div.nblast.container {
    padding-bottom: 5px;
}

/* input prompt */
div.nbinput.container div.prompt pre {
    color: #307FC1;
}

/* output prompt */
div.nboutput.container div.prompt pre {
    color: #BF5B3D;
}

/* all prompts */
div.nbinput.container div.prompt,
div.nboutput.container div.prompt {
    width: 4.5ex;
    padding-top: 5px;
    position: relative;
    user-select: none;
}

div.nbinput.container div.prompt > div,
div.nboutput.container div.prompt > div {
    position: absolute;
    right: 0;
    margin-right: 0.3ex;
}

@media (max-width: 540px) {
    div.nbinput.container div.prompt,
    div.nboutput.container div.prompt {
        width: unset;
        text-align: left;
        padding: 0.4em;
    }
    div.nboutput.container div.prompt.empty {
        padding: 0;
    }

    div.nbinput.container div.prompt > div,
    div.nboutput.container div.prompt > div {
        position: unset;
    }
}

/* disable scrollbars on prompts */
div.nbinput.container div.prompt pre,
div.nboutput.container div.prompt pre {
    overflow: hidden;
}

/* input/output area */
div.nbinput.container div.input_area,
div.nboutput.container div.output_area {
    -webkit-flex: 1;
    flex: 1;
    overflow: auto;
}
@media (max-width: 540px) {
    div.nbinput.container div.input_area,
    div.nboutput.container div.output_area {
        width: 100%;
    }
}

/* input area */
div.nbinput.container div.input_area {
    border: 1px solid #e0e0e0;
    border-radius: 2px;
    /*background: #f5f5f5;*/
}

/* override MathJax center alignment in output cells */
div.nboutput.container div[class*=MathJax] {
    text-align: left !important;
}

/* override sphinx.ext.imgmath center alignment in output cells */
div.nboutput.container div.math p {
    text-align: left;
}

/* standard error */
div.nboutput.container div.output_area.stderr {
    background: #fdd;
}

/* ANSI colors */
.ansi-black-fg { color: #3E424D; }
.ansi-black-bg { background-color: #3E424D; }
.ansi-black-intense-fg { color: #282C36; }
.ansi-black-intense-bg { background-color: #282C36; }
.ansi-red-fg { color: #E75C58; }
.ansi-red-bg { background-color: #E75C58; }
.ansi-red-intense-fg { color: #B22B31; }
.ansi-red-intense-bg { background-color: #B22B31; }
.ansi-green-fg { color: #00A250; }
.ansi-green-bg { background-color: #00A250; }
.ansi-green-intense-fg { color: #007427; }
.ansi-green-intense-bg { background-color: #007427; }
.ansi-yellow-fg { color: #DDB62B; }
.ansi-yellow-bg { background-color: #DDB62B; }
.ansi-yellow-intense-fg { color: #B27D12; }
.ansi-yellow-intense-bg { background-color: #B27D12; }
.ansi-blue-fg { color: #208FFB; }
.ansi-blue-bg { background-color: #208FFB; }
.ansi-blue-intense-fg { color: #0065CA; }
.ansi-blue-intense-bg { background-color: #0065CA; }
.ansi-magenta-fg { color: #D160C4; }
.ansi-magenta-bg { background-color: #D160C4; }
.ansi-magenta-intense-fg { color: #A03196; }
.ansi-magenta-intense-bg { background-color: #A03196; }
.ansi-cyan-fg { color: #60C6C8; }
.ansi-cyan-bg { background-color: #60C6C8; }
.ansi-cyan-intense-fg { color: #258F8F; }
.ansi-cyan-intense-bg { background-color: #258F8F; }
.ansi-white-fg { color: #C5C1B4; }
.ansi-white-bg { background-color: #C5C1B4; }
.ansi-white-intense-fg { color: #A1A6B2; }
.ansi-white-intense-bg { background-color: #A1A6B2; }

.ansi-default-inverse-fg { color: #FFFFFF; }
.ansi-default-inverse-bg { background-color: #000000; }

.ansi-bold { font-weight: bold; }
.ansi-underline { text-decoration: underline; }


div.nbinput.container div.input_area div[class*=highlight] > pre,
div.nboutput.container div.output_area div[class*=highlight] > pre,
div.nboutput.container div.output_area div[class*=highlight].math,
div.nboutput.container div.output_area.rendered_html,
div.nboutput.container div.output_area > div.output_javascript,
div.nboutput.container div.output_area:not(.rendered_html) > img{
    padding: 5px;
    margin: 0;
}

/* fix copybtn overflow problem in chromium (needed for 'sphinx_copybutton') */
div.nbinput.container div.input_area > div[class^='highlight'],
div.nboutput.container div.output_area > div[class^='highlight']{
    overflow-y: hidden;
}

/* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */
.prompt a.copybtn {
    display: none;
}

/* Some additional styling taken form the Jupyter notebook CSS */
div.rendered_html table {
  border: none;
  border-collapse: collapse;
  border-spacing: 0;
  color: black;
  font-size: 12px;
  table-layout: fixed;
}
div.rendered_html thead {
  border-bottom: 1px solid black;
  vertical-align: bottom;
}
div.rendered_html tr,
div.rendered_html th,
div.rendered_html td {
  text-align: right;
  vertical-align: middle;
  padding: 0.5em 0.5em;
  line-height: normal;
  white-space: normal;
  max-width: none;
  border: none;
}
div.rendered_html th {
  font-weight: bold;
}
div.rendered_html tbody tr:nth-child(odd) {
  background: #f5f5f5;
}
div.rendered_html tbody tr:hover {
  background: rgba(66, 165, 245, 0.2);
}
</style>
<div class="section" id="Introduction-to-atomman:-system_model-conversions">
<h1>Introduction to atomman: system_model conversions<a class="headerlink" href="#Introduction-to-atomman:-system_model-conversions" title="Permalink to this headline">¶</a></h1>
<p><strong>Lucas M. Hale</strong>, <a class="reference external" href="mailto:lucas&#46;hale&#37;&#52;&#48;nist&#46;gov?Subject=ipr-demo">lucas<span>&#46;</span>hale<span>&#64;</span>nist<span>&#46;</span>gov</a>, <em>Materials Science and Engineering Division, NIST</em>.</p>
<p><a class="reference external" href="http://www.nist.gov/public_affairs/disclaimer.cfm">Disclaimers</a></p>
<div class="section" id="1.-Introduction">
<h2>1. Introduction<a class="headerlink" href="#1.-Introduction" title="Permalink to this headline">¶</a></h2>
<p>The system_model format provides a direct representation of an atomman.System object that can be equivalently saved as either JSON or XML atomman.System class. As it is specifically designed for the System class, it captures all information about the system.</p>
<div class="section" id="1.1.-Notes-on-the-system-model-format">
<h3>1.1. Notes on the system model format<a class="headerlink" href="#1.1.-Notes-on-the-system-model-format" title="Permalink to this headline">¶</a></h3>
<p>The system model format was updated starting atomman version 1.2.7. This format change was done to provide consistent representation of the system in data model format with respect to other atomman objects and to ensure that all data defining the System class is captured in the data model. Subsequent versions of atomman may add fields to the model if the System class adds representations for them, but will likely remain compatible with any version of atomman after 1.2.7. Unfortunately, the
system models generated by versions of atomman &lt;= 1.2.6 are distinctly different and therefore not compatible or supported anymore.</p>
<p>The sytem model format is a tree-like structure, with a single root element, “atomic-system”, and multiple subelements. For consistency with the other atomman objects, the System model contains the models for the system’s box and atoms. Expressing paths using periods to separate elements and subelements, the model consists of:</p>
<ul class="simple">
<li><p>“atomic-system.box” is the model for the System’s Box containing values for the vects and the origin.</p></li>
<li><p>“atomic-system.periodic-boundary-condition” lists the three boolean pbc values.</p></li>
<li><p>“atomic-system.atomic-type-symbol” lists the symbols associated with each atom type.</p></li>
<li><p>“atomic-system.atomic-type-mass” <em>Added version 1.3.0</em> lists the masses associated with each atom type, if any were assigned.</p></li>
<li><p>“atomic-system.atoms” is the model for the System’s Atoms and contains all per-atom values.</p></li>
</ul>
<p>Consistent with atomman.unitconvert.model(), all multidimensional data is represented as a flattened array combined with shape parameters. This choice allows the data model to be equivalently represented as JSON or XML while remaining optimized for JSON/Python-based handling.</p>
<p><strong>Library Imports</strong></p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Standard Python libraries</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">datetime</span>

<span class="c1"># http://www.numpy.org/</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="c1"># https://github.com/usnistgov/DataModelDict</span>
<span class="kn">from</span> <span class="nn">DataModelDict</span> <span class="k">import</span> <span class="n">DataModelDict</span> <span class="k">as</span> <span class="n">DM</span>

<span class="c1"># https://github.com/usnistgov/atomman</span>
<span class="kn">import</span> <span class="nn">atomman</span> <span class="k">as</span> <span class="nn">am</span>
<span class="kn">import</span> <span class="nn">atomman.unitconvert</span> <span class="k">as</span> <span class="nn">uc</span>

<span class="c1"># Show atomman version</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;atomman version =&#39;</span><span class="p">,</span> <span class="n">am</span><span class="o">.</span><span class="n">__version__</span><span class="p">)</span>

<span class="c1"># Show date of Notebook execution</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Notebook executed on&#39;</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">today</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
atomman version = 1.4.0
Notebook executed on 2021-08-03
</pre></div></div>
</div>
<p>Generate test system information (CsCl)</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Generate box</span>
<span class="n">alat</span> <span class="o">=</span> <span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="mf">3.2</span><span class="p">,</span> <span class="s1">&#39;angstrom&#39;</span><span class="p">)</span>
<span class="n">box</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">Box</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="n">alat</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="n">alat</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="n">alat</span><span class="p">)</span>

<span class="c1"># Generate atoms with atype, pos, charge, and stress properties</span>
<span class="n">atype</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span>
<span class="n">pos</span> <span class="o">=</span> <span class="p">[[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">]]</span>
<span class="n">charge</span> <span class="o">=</span> <span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="s1">&#39;e&#39;</span><span class="p">)</span>
<span class="n">stress</span> <span class="o">=</span> <span class="n">uc</span><span class="o">.</span><span class="n">set_in_units</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">)),</span> <span class="s1">&#39;MPa&#39;</span><span class="p">)</span>
<span class="n">atoms</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">Atoms</span><span class="p">(</span><span class="n">pos</span><span class="o">=</span><span class="n">pos</span><span class="p">,</span> <span class="n">atype</span><span class="o">=</span><span class="n">atype</span><span class="p">,</span> <span class="n">charge</span><span class="o">=</span><span class="n">charge</span><span class="p">,</span> <span class="n">stress</span><span class="o">=</span><span class="n">stress</span><span class="p">)</span>

<span class="c1"># Build system from box and atoms, and scale atoms</span>
<span class="n">system</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">System</span><span class="p">(</span><span class="n">atoms</span><span class="o">=</span><span class="n">atoms</span><span class="p">,</span> <span class="n">box</span><span class="o">=</span><span class="n">box</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">symbols</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;Cs&#39;</span><span class="p">,</span> <span class="s1">&#39;Cl&#39;</span><span class="p">])</span>

<span class="c1"># Print system information</span>
<span class="nb">print</span><span class="p">(</span><span class="n">system</span><span class="p">)</span>
<span class="n">system</span><span class="o">.</span><span class="n">atoms_df</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="nboutput docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
avect =  [ 3.200,  0.000,  0.000]
bvect =  [ 0.000,  3.200,  0.000]
cvect =  [ 0.000,  0.000,  3.200]
origin = [ 0.000,  0.000,  0.000]
natoms = 2
natypes = 2
symbols = (&#39;Cs&#39;, &#39;Cl&#39;)
pbc = [ True  True  True]
per-atom properties = [&#39;atype&#39;, &#39;pos&#39;, &#39;charge&#39;, &#39;stress&#39;]
     id |   atype |  pos[0] |  pos[1] |  pos[2]
      0 |       1 |   0.000 |   0.000 |   0.000
      1 |       2 |   1.600 |   1.600 |   1.600
</pre></div></div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]:
</pre></div>
</div>
<div class="output_area rendered_html docutils container">
<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>atype</th>
      <th>pos[0]</th>
      <th>pos[1]</th>
      <th>pos[2]</th>
      <th>charge</th>
      <th>stress[0][0]</th>
      <th>stress[0][1]</th>
      <th>stress[0][2]</th>
      <th>stress[1][0]</th>
      <th>stress[1][1]</th>
      <th>stress[1][2]</th>
      <th>stress[2][0]</th>
      <th>stress[2][1]</th>
      <th>stress[2][2]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>0</td>
      <td>1</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>1.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>1.6</td>
      <td>1.6</td>
      <td>1.6</td>
      <td>-1.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
    </tr>
  </tbody>
</table>
</div></div>
</div>
</div>
</div>
<div class="section" id="2.-Dump">
<h2>2. Dump<a class="headerlink" href="#2.-Dump" title="Permalink to this headline">¶</a></h2>
<div class="section" id="2.1.-System.model()">
<h3>2.1. System.model()<a class="headerlink" href="#2.1.-System.model()" title="Permalink to this headline">¶</a></h3>
<p>Similar to other atomman classes, the System class has a model() method that generates a data model representation for the object. This allows for all content of the system to be saved as either JSON or XML, and reloaded later by initializing a new System object using the model.</p>
<p>Parameters</p>
<ul class="simple">
<li><p><strong>box_unit</strong> (<em>str, optional</em>) Length unit to use for the box. Default value is ‘angstrom’.</p></li>
<li><p><strong>prop_name</strong> (<em>list, optional</em>) The Atoms properties to include. If neither prop_name nor prop_unit are given, all system properties will be included.</p></li>
<li><p><strong>unit</strong> (<em>list, optional</em>) Lists the units for each prop_name as stored in the table. For a value of None, no conversion will be performed for that property. For a value of ‘scaled’, the corresponding table values will be taken in box-scaled units. If neither unit nor prop_units given, pos will be given in Angstroms and all other values will not be converted.</p></li>
<li><p><strong>prop_unit</strong> (<em>dict, optional</em>) dictionary where the keys are the property keys to include, and the values are units to use. If neither unit nor prop_units given, pos will be given in Angstroms and all other values will not be converted.</p></li>
</ul>
<p>Returns</p>
<ul class="simple">
<li><p>(<em>DataModelDict.DataModelDict</em>) A JSON/XML data model for the current System object.</p></li>
</ul>
<div class="section" id="2.1.1.-Simple-example">
<h4>2.1.1. Simple example<a class="headerlink" href="#2.1.1.-Simple-example" title="Permalink to this headline">¶</a></h4>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Retrieve model as a DataModelDict using model</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">system</span><span class="o">.</span><span class="n">model</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="n">model</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
DataModelDict([(&#39;atomic-system&#39;, DataModelDict([(&#39;box&#39;, DataModelDict([(&#39;avect&#39;, DataModelDict([(&#39;value&#39;, [3.2, 0.0, 0.0])])), (&#39;bvect&#39;, DataModelDict([(&#39;value&#39;, [0.0, 3.2, 0.0])])), (&#39;cvect&#39;, DataModelDict([(&#39;value&#39;, [0.0, 0.0, 3.2])])), (&#39;origin&#39;, DataModelDict([(&#39;value&#39;, [0.0, 0.0, 0.0])]))])), (&#39;periodic-boundary-condition&#39;, [True, True, True]), (&#39;atom-type-symbol&#39;, [&#39;Cs&#39;, &#39;Cl&#39;]), (&#39;atoms&#39;, DataModelDict([(&#39;natoms&#39;, 2), (&#39;property&#39;, [DataModelDict([(&#39;name&#39;, &#39;atype&#39;), (&#39;data&#39;, DataModelDict([(&#39;value&#39;, [1, 2])]))]), DataModelDict([(&#39;name&#39;, &#39;pos&#39;), (&#39;data&#39;, DataModelDict([(&#39;value&#39;, [0.0, 0.0, 0.0, 1.6, 1.6, 1.6]), (&#39;shape&#39;, [2, 3]), (&#39;unit&#39;, &#39;angstrom&#39;)]))]), DataModelDict([(&#39;name&#39;, &#39;charge&#39;), (&#39;data&#39;, DataModelDict([(&#39;value&#39;, [1.0, -1.0])]))]), DataModelDict([(&#39;name&#39;, &#39;stress&#39;), (&#39;data&#39;, DataModelDict([(&#39;value&#39;, [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), (&#39;shape&#39;, [2, 3, 3])]))])])]))]))])
</pre></div></div>
</div>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Convert model to JSON</span>
<span class="nb">print</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">json</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
{&#34;atomic-system&#34;: {&#34;box&#34;: {&#34;avect&#34;: {&#34;value&#34;: [3.2, 0.0, 0.0]}, &#34;bvect&#34;: {&#34;value&#34;: [0.0, 3.2, 0.0]}, &#34;cvect&#34;: {&#34;value&#34;: [0.0, 0.0, 3.2]}, &#34;origin&#34;: {&#34;value&#34;: [0.0, 0.0, 0.0]}}, &#34;periodic-boundary-condition&#34;: [true, true, true], &#34;atom-type-symbol&#34;: [&#34;Cs&#34;, &#34;Cl&#34;], &#34;atoms&#34;: {&#34;natoms&#34;: 2, &#34;property&#34;: [{&#34;name&#34;: &#34;atype&#34;, &#34;data&#34;: {&#34;value&#34;: [1, 2]}}, {&#34;name&#34;: &#34;pos&#34;, &#34;data&#34;: {&#34;value&#34;: [0.0, 0.0, 0.0, 1.6, 1.6, 1.6], &#34;shape&#34;: [2, 3], &#34;unit&#34;: &#34;angstrom&#34;}}, {&#34;name&#34;: &#34;charge&#34;, &#34;data&#34;: {&#34;value&#34;: [1.0, -1.0]}}, {&#34;name&#34;: &#34;stress&#34;, &#34;data&#34;: {&#34;value&#34;: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], &#34;shape&#34;: [2, 3, 3]}}]}}}
</pre></div></div>
</div>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Convert model to XML</span>
<span class="nb">print</span><span class="p">(</span><span class="n">model</span><span class="o">.</span><span class="n">xml</span><span class="p">())</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
&lt;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&gt;
&lt;atomic-system&gt;&lt;box&gt;&lt;avect&gt;&lt;value&gt;3.2&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;/avect&gt;&lt;bvect&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;3.2&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;/bvect&gt;&lt;cvect&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;3.2&lt;/value&gt;&lt;/cvect&gt;&lt;origin&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;/origin&gt;&lt;/box&gt;&lt;periodic-boundary-condition&gt;True&lt;/periodic-boundary-condition&gt;&lt;periodic-boundary-condition&gt;True&lt;/periodic-boundary-condition&gt;&lt;periodic-boundary-condition&gt;True&lt;/periodic-boundary-condition&gt;&lt;atom-type-symbol&gt;Cs&lt;/atom-type-symbol&gt;&lt;atom-type-symbol&gt;Cl&lt;/atom-type-symbol&gt;&lt;atoms&gt;&lt;natoms&gt;2&lt;/natoms&gt;&lt;property&gt;&lt;name&gt;atype&lt;/name&gt;&lt;data&gt;&lt;value&gt;1&lt;/value&gt;&lt;value&gt;2&lt;/value&gt;&lt;/data&gt;&lt;/property&gt;&lt;property&gt;&lt;name&gt;pos&lt;/name&gt;&lt;data&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;1.6&lt;/value&gt;&lt;value&gt;1.6&lt;/value&gt;&lt;value&gt;1.6&lt;/value&gt;&lt;shape&gt;2&lt;/shape&gt;&lt;shape&gt;3&lt;/shape&gt;&lt;unit&gt;angstrom&lt;/unit&gt;&lt;/data&gt;&lt;/property&gt;&lt;property&gt;&lt;name&gt;charge&lt;/name&gt;&lt;data&gt;&lt;value&gt;1.0&lt;/value&gt;&lt;value&gt;-1.0&lt;/value&gt;&lt;/data&gt;&lt;/property&gt;&lt;property&gt;&lt;name&gt;stress&lt;/name&gt;&lt;data&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;shape&gt;2&lt;/shape&gt;&lt;shape&gt;3&lt;/shape&gt;&lt;shape&gt;3&lt;/shape&gt;&lt;/data&gt;&lt;/property&gt;&lt;/atoms&gt;&lt;/atomic-system&gt;
</pre></div></div>
</div>
</div>
<div class="section" id="2.1.2.-Specify-units-and/or-limit-included-properties">
<h4>2.1.2. Specify units and/or limit included properties<a class="headerlink" href="#2.1.2.-Specify-units-and/or-limit-included-properties" title="Permalink to this headline">¶</a></h4>
<p>By default, all per-atom properties will be saved to the data model. Since freely-assigned properties can theoretically be in any unit, the values will be saved in atomman’s working units if no unit information is provided. This implicitly assumes that atomman will be used to read the data back in, and that atomman’s working units during dumping and loading are the same.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Show (lack of) units as set in the model above</span>
<span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">model</span><span class="o">.</span><span class="n">finds</span><span class="p">(</span><span class="s1">&#39;property&#39;</span><span class="p">):</span>
    <span class="n">name</span> <span class="o">=</span> <span class="n">prop</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
    <span class="n">unit</span> <span class="o">=</span> <span class="n">prop</span><span class="p">[</span><span class="s1">&#39;data&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;unit&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="s1">&#39;</span><span class="si">{name}</span><span class="s1"> is in units </span><span class="si">{unit}</span><span class="s1">&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
atype is in units None
pos is in units angstrom
charge is in units None
stress is in units None
</pre></div></div>
</div>
<p>The units that the values are saved in can be explicitly set by providing a list that gives a unit for each of the set per-atom properties in the order that System.atoms_prop() lists them.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">model2</span> <span class="o">=</span> <span class="n">system</span><span class="o">.</span><span class="n">model</span><span class="p">(</span><span class="n">unit</span><span class="o">=</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="s1">&#39;nm&#39;</span><span class="p">,</span> <span class="s1">&#39;e&#39;</span><span class="p">,</span> <span class="s1">&#39;GPa&#39;</span><span class="p">])</span>

<span class="c1"># Show units are now assigned</span>
<span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">model2</span><span class="o">.</span><span class="n">finds</span><span class="p">(</span><span class="s1">&#39;property&#39;</span><span class="p">):</span>
    <span class="n">name</span> <span class="o">=</span> <span class="n">prop</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
    <span class="n">unit</span> <span class="o">=</span> <span class="n">prop</span><span class="p">[</span><span class="s1">&#39;data&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;unit&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="s1">&#39;</span><span class="si">{name}</span><span class="s1"> is in units </span><span class="si">{unit}</span><span class="s1">&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
atype is in units None
pos is in units nm
charge is in units e
stress is in units GPa
</pre></div></div>
</div>
<p>Properties can also be excluded from the data model by using prop_name to list only the wanted properties. In that case, the unit values should match with the prop_name values.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[8]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">model2</span> <span class="o">=</span> <span class="n">system</span><span class="o">.</span><span class="n">model</span><span class="p">(</span><span class="n">prop_name</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;atype&#39;</span><span class="p">,</span> <span class="s1">&#39;pos&#39;</span><span class="p">,</span> <span class="s1">&#39;stress&#39;</span><span class="p">],</span>
                      <span class="n">unit</span><span class="o">=</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="s1">&#39;nm&#39;</span><span class="p">,</span> <span class="s1">&#39;GPa&#39;</span><span class="p">])</span>

<span class="c1"># Show units are now assigned</span>
<span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">model2</span><span class="o">.</span><span class="n">finds</span><span class="p">(</span><span class="s1">&#39;property&#39;</span><span class="p">):</span>
    <span class="n">name</span> <span class="o">=</span> <span class="n">prop</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
    <span class="n">unit</span> <span class="o">=</span> <span class="n">prop</span><span class="p">[</span><span class="s1">&#39;data&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;unit&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="s1">&#39;</span><span class="si">{name}</span><span class="s1"> is in units </span><span class="si">{unit}</span><span class="s1">&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
atype is in units None
pos is in units nm
stress is in units GPa
</pre></div></div>
</div>
<p>For convenience, the unit and property choice can alternatively be represented in dictionary format and passed in using the prop_unit parameter.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[9]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">prop_unit</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">prop_unit</span><span class="p">[</span><span class="s1">&#39;atype&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">prop_unit</span><span class="p">[</span><span class="s1">&#39;pos&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;nm&#39;</span>
<span class="n">prop_unit</span><span class="p">[</span><span class="s1">&#39;charge&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;e&#39;</span>

<span class="n">model2</span> <span class="o">=</span> <span class="n">system</span><span class="o">.</span><span class="n">model</span><span class="p">(</span><span class="n">prop_unit</span><span class="o">=</span><span class="n">prop_unit</span><span class="p">)</span>

<span class="c1"># Show units are now assigned</span>
<span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">model2</span><span class="o">.</span><span class="n">finds</span><span class="p">(</span><span class="s1">&#39;property&#39;</span><span class="p">):</span>
    <span class="n">name</span> <span class="o">=</span> <span class="n">prop</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
    <span class="n">unit</span> <span class="o">=</span> <span class="n">prop</span><span class="p">[</span><span class="s1">&#39;data&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;unit&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="s1">&#39;</span><span class="si">{name}</span><span class="s1"> is in units </span><span class="si">{unit}</span><span class="s1">&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
atype is in units None
pos is in units nm
charge is in units e
</pre></div></div>
</div>
</div>
</div>
<div class="section" id="2.2.-System.dump(‘system_model’)">
<h3>2.2. System.dump(‘system_model’)<a class="headerlink" href="#2.2.-System.dump(‘system_model’)" title="Permalink to this headline">¶</a></h3>
<p>Alternatively, a model of the system can be generated by calling the System.dump() method using the ‘system_model’ style. This allows for consistency with the other System-level conversions. There is no difference in the resulting models produced by the two methods as System.dump() calls System.model().</p>
<p>Parameters</p>
<ul class="simple">
<li><p><strong>f</strong> (<em>str or file-like object, optional</em>) File path or file-like object to write the content to. If not given, then the content is returned.</p></li>
<li><p><strong>box_unit</strong> (<em>str, optional</em>) Length unit to use for the box. Default value is ‘angstrom’.</p></li>
<li><p><strong>prop_name</strong> (<em>list, optional</em>) The Atoms properties to include. If neither prop_name nor prop_unit are given, all system properties will be included.</p></li>
<li><p><strong>unit</strong> (<em>list, optional</em>) Lists the units for each prop_name as stored in the table. For a value of None, no conversion will be performed for that property. For a value of ‘scaled’, the corresponding table values will be taken in box-scaled units. If neither unit nor prop_units given, pos will be given in Angstroms and all other values will not be converted.</p></li>
<li><p><strong>prop_unit</strong> (<em>dict, optional</em>) dictionary where the keys are the property keys to include, and the values are units to use. If neither unit nor prop_units given, pos will be given in Angstroms and all other values will not be converted.</p></li>
<li><p><strong>format</strong> (<em>str, optional</em>) File format ‘xml’ or ‘json’ to save the content as if f is given. If f is a filename, then the format will be automatically inferred from f’s extension. If format is not given and cannot be inferred, then it will be set to ‘json’.</p></li>
<li><p><strong>indent</strong> (<em>int or None, optional</em>) Indentation option to use for XML/JSON content if f is given. A value of None (default) will add no line separatations or indentations.</p></li>
</ul>
<p>Returns</p>
<ul class="simple">
<li><p><strong>model</strong> (<em>DataModelDict.DataModelDict or str</em>) The generated model representation of the system. Will be a DataModelDict if format is not specified, and a JSON- or XML-formatted string if format is specified. Returned if f is not given.</p></li>
</ul>
<div class="section" id="2.2.1.-Simple-example">
<h4>2.2.1. Simple example<a class="headerlink" href="#2.2.1.-Simple-example" title="Permalink to this headline">¶</a></h4>
<p>As System.dump(‘system_model’) calls System.model(), most parameters of the two functions are the same.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[10]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">model</span> <span class="o">=</span> <span class="n">system</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="s1">&#39;system_model&#39;</span><span class="p">,</span> <span class="n">prop_unit</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;atype&#39;</span><span class="p">:</span><span class="kc">None</span><span class="p">,</span> <span class="s1">&#39;pos&#39;</span><span class="p">:</span><span class="s1">&#39;scaled&#39;</span><span class="p">,</span> <span class="s1">&#39;charge&#39;</span><span class="p">:</span> <span class="s1">&#39;e&#39;</span><span class="p">,</span> <span class="s1">&#39;stress&#39;</span><span class="p">:</span> <span class="s1">&#39;GPa&#39;</span><span class="p">})</span>
<span class="nb">print</span><span class="p">(</span><span class="n">model</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
DataModelDict([(&#39;atomic-system&#39;, DataModelDict([(&#39;box&#39;, DataModelDict([(&#39;avect&#39;, DataModelDict([(&#39;value&#39;, [3.2, 0.0, 0.0])])), (&#39;bvect&#39;, DataModelDict([(&#39;value&#39;, [0.0, 3.2, 0.0])])), (&#39;cvect&#39;, DataModelDict([(&#39;value&#39;, [0.0, 0.0, 3.2])])), (&#39;origin&#39;, DataModelDict([(&#39;value&#39;, [0.0, 0.0, 0.0])]))])), (&#39;periodic-boundary-condition&#39;, [True, True, True]), (&#39;atom-type-symbol&#39;, [&#39;Cs&#39;, &#39;Cl&#39;]), (&#39;atoms&#39;, DataModelDict([(&#39;natoms&#39;, 2), (&#39;property&#39;, [DataModelDict([(&#39;name&#39;, &#39;atype&#39;), (&#39;data&#39;, DataModelDict([(&#39;value&#39;, [1, 2])]))]), DataModelDict([(&#39;name&#39;, &#39;pos&#39;), (&#39;data&#39;, DataModelDict([(&#39;value&#39;, [0.0, 0.0, 0.0, 0.5, 0.5, 0.5]), (&#39;shape&#39;, [2, 3]), (&#39;unit&#39;, &#39;scaled&#39;)]))]), DataModelDict([(&#39;name&#39;, &#39;charge&#39;), (&#39;data&#39;, DataModelDict([(&#39;value&#39;, [1.0, -1.0]), (&#39;unit&#39;, &#39;e&#39;)]))]), DataModelDict([(&#39;name&#39;, &#39;stress&#39;), (&#39;data&#39;, DataModelDict([(&#39;value&#39;, [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), (&#39;shape&#39;, [2, 3, 3]), (&#39;unit&#39;, &#39;GPa&#39;)]))])])]))]))])
</pre></div></div>
</div>
<p>The primary difference is that System.dump(‘atom_model’) can directly convert to JSON/XML and save to a file.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[11]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">model_json</span> <span class="o">=</span> <span class="n">system</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="s1">&#39;system_model&#39;</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s1">&#39;json&#39;</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                         <span class="n">prop_unit</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;atype&#39;</span><span class="p">:</span><span class="kc">None</span><span class="p">,</span> <span class="s1">&#39;pos&#39;</span><span class="p">:</span><span class="s1">&#39;scaled&#39;</span><span class="p">})</span>
<span class="nb">print</span><span class="p">(</span><span class="n">model_json</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
{
  &#34;atomic-system&#34;: {
    &#34;box&#34;: {
      &#34;avect&#34;: {
        &#34;value&#34;: [
          3.2,
          0.0,
          0.0
        ]
      },
      &#34;bvect&#34;: {
        &#34;value&#34;: [
          0.0,
          3.2,
          0.0
        ]
      },
      &#34;cvect&#34;: {
        &#34;value&#34;: [
          0.0,
          0.0,
          3.2
        ]
      },
      &#34;origin&#34;: {
        &#34;value&#34;: [
          0.0,
          0.0,
          0.0
        ]
      }
    },
    &#34;periodic-boundary-condition&#34;: [
      true,
      true,
      true
    ],
    &#34;atom-type-symbol&#34;: [
      &#34;Cs&#34;,
      &#34;Cl&#34;
    ],
    &#34;atoms&#34;: {
      &#34;natoms&#34;: 2,
      &#34;property&#34;: [
        {
          &#34;name&#34;: &#34;atype&#34;,
          &#34;data&#34;: {
            &#34;value&#34;: [
              1,
              2
            ]
          }
        },
        {
          &#34;name&#34;: &#34;pos&#34;,
          &#34;data&#34;: {
            &#34;value&#34;: [
              0.0,
              0.0,
              0.0,
              0.5,
              0.5,
              0.5
            ],
            &#34;shape&#34;: [
              2,
              3
            ],
            &#34;unit&#34;: &#34;scaled&#34;
          }
        }
      ]
    }
  }
}
</pre></div></div>
</div>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[12]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Save to file as XML</span>
<span class="n">system</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="s1">&#39;system_model&#39;</span><span class="p">,</span> <span class="n">f</span><span class="o">=</span><span class="s1">&#39;model.xml&#39;</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s1">&#39;xml&#39;</span><span class="p">,</span>
            <span class="n">prop_unit</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;atype&#39;</span><span class="p">:</span><span class="kc">None</span><span class="p">,</span> <span class="s1">&#39;pos&#39;</span><span class="p">:</span><span class="s1">&#39;scaled&#39;</span><span class="p">})</span>

<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;model.xml&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>

<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s1">&#39;model.xml&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
&lt;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&gt;
&lt;atomic-system&gt;&lt;box&gt;&lt;avect&gt;&lt;value&gt;3.2&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;/avect&gt;&lt;bvect&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;3.2&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;/bvect&gt;&lt;cvect&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;3.2&lt;/value&gt;&lt;/cvect&gt;&lt;origin&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;/origin&gt;&lt;/box&gt;&lt;periodic-boundary-condition&gt;True&lt;/periodic-boundary-condition&gt;&lt;periodic-boundary-condition&gt;True&lt;/periodic-boundary-condition&gt;&lt;periodic-boundary-condition&gt;True&lt;/periodic-boundary-condition&gt;&lt;atom-type-symbol&gt;Cs&lt;/atom-type-symbol&gt;&lt;atom-type-symbol&gt;Cl&lt;/atom-type-symbol&gt;&lt;atoms&gt;&lt;natoms&gt;2&lt;/natoms&gt;&lt;property&gt;&lt;name&gt;atype&lt;/name&gt;&lt;data&gt;&lt;value&gt;1&lt;/value&gt;&lt;value&gt;2&lt;/value&gt;&lt;/data&gt;&lt;/property&gt;&lt;property&gt;&lt;name&gt;pos&lt;/name&gt;&lt;data&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.0&lt;/value&gt;&lt;value&gt;0.5&lt;/value&gt;&lt;value&gt;0.5&lt;/value&gt;&lt;value&gt;0.5&lt;/value&gt;&lt;shape&gt;2&lt;/shape&gt;&lt;shape&gt;3&lt;/shape&gt;&lt;unit&gt;scaled&lt;/unit&gt;&lt;/data&gt;&lt;/property&gt;&lt;/atoms&gt;&lt;/atomic-system&gt;
</pre></div></div>
</div>
</div>
</div>
</div>
<div class="section" id="3.-Load">
<h2>3. Load<a class="headerlink" href="#3.-Load" title="Permalink to this headline">¶</a></h2>
<div class="section" id="3.1.-System.__init__(model)">
<h3>3.1. System.__init__(model)<a class="headerlink" href="#3.1.-System.__init__(model)" title="Permalink to this headline">¶</a></h3>
<p>A model can be interpreted by passing it as a parameter when initializing a new System object. Note that the supplied model value can be a DataModelDict, a JSON or XML string, or the name of a JSON or XML file.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Initialize new system using model</span>
<span class="n">system2</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">System</span><span class="p">(</span><span class="n">model</span><span class="o">=</span><span class="n">model</span><span class="p">)</span>

<span class="c1"># Print system information</span>
<span class="nb">print</span><span class="p">(</span><span class="n">system2</span><span class="p">)</span>
<span class="n">system2</span><span class="o">.</span><span class="n">atoms_df</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="nboutput docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
avect =  [ 3.200,  0.000,  0.000]
bvect =  [ 0.000,  3.200,  0.000]
cvect =  [ 0.000,  0.000,  3.200]
origin = [ 0.000,  0.000,  0.000]
natoms = 2
natypes = 2
symbols = (&#39;Cs&#39;, &#39;Cl&#39;)
pbc = [ True  True  True]
per-atom properties = [&#39;atype&#39;, &#39;pos&#39;, &#39;charge&#39;, &#39;stress&#39;]
     id |   atype |  pos[0] |  pos[1] |  pos[2]
      0 |       1 |   0.000 |   0.000 |   0.000
      1 |       2 |   1.600 |   1.600 |   1.600
</pre></div></div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[13]:
</pre></div>
</div>
<div class="output_area rendered_html docutils container">
<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>atype</th>
      <th>pos[0]</th>
      <th>pos[1]</th>
      <th>pos[2]</th>
      <th>charge</th>
      <th>stress[0][0]</th>
      <th>stress[0][1]</th>
      <th>stress[0][2]</th>
      <th>stress[1][0]</th>
      <th>stress[1][1]</th>
      <th>stress[1][2]</th>
      <th>stress[2][0]</th>
      <th>stress[2][1]</th>
      <th>stress[2][2]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>0</td>
      <td>1</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>1.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>1.6</td>
      <td>1.6</td>
      <td>1.6</td>
      <td>-1.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
    </tr>
  </tbody>
</table>
</div></div>
</div>
</div>
<div class="section" id="3.2.-atomman.load(‘system_model’)">
<h3>3.2. atomman.load(‘system_model’)<a class="headerlink" href="#3.2.-atomman.load(‘system_model’)" title="Permalink to this headline">¶</a></h3>
<p>The atomman.load() function with the’system_model’ style also supports reading System.model content.</p>
<p>Parameters</p>
<ul class="simple">
<li><p><strong>model</strong> (<em>str, file-like object or DataModelDict</em>) The data model to read.</p></li>
<li><p><strong>symbols</strong> (<em>tuple, optional</em>) Allows the list of element symbols to be assigned during loading.</p></li>
<li><p><strong>key</strong> (<em>str, optional</em>) The key identifying the root element for the system definition. Default value is ‘atomic-system’.</p></li>
<li><p><strong>index</strong> (<em>int, optional</em>) If the full model has multiple key entries, the index specifies which to access. Default value is 0 (first, or only entry).</p></li>
</ul>
<p>Returns</p>
<ul class="simple">
<li><p><strong>system</strong> (<em>atomman.System</em>) The system object associated with the data model.</p></li>
</ul>
<div class="section" id="3.2.1.-Examples">
<h4>3.2.1. Examples<a class="headerlink" href="#3.2.1.-Examples" title="Permalink to this headline">¶</a></h4>
<p>The default behavior of atomman.load() is identical to initializing a new System object using the model.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[14]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="n">model_system</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s1">&#39;system_model&#39;</span><span class="p">,</span> <span class="n">model</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">model_system</span><span class="p">)</span>
<span class="n">model_system</span><span class="o">.</span><span class="n">atoms_df</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="nboutput docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
avect =  [ 3.200,  0.000,  0.000]
bvect =  [ 0.000,  3.200,  0.000]
cvect =  [ 0.000,  0.000,  3.200]
origin = [ 0.000,  0.000,  0.000]
natoms = 2
natypes = 2
symbols = (&#39;Cs&#39;, &#39;Cl&#39;)
pbc = [ True  True  True]
per-atom properties = [&#39;atype&#39;, &#39;pos&#39;, &#39;charge&#39;, &#39;stress&#39;]
     id |   atype |  pos[0] |  pos[1] |  pos[2]
      0 |       1 |   0.000 |   0.000 |   0.000
      1 |       2 |   1.600 |   1.600 |   1.600
</pre></div></div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[14]:
</pre></div>
</div>
<div class="output_area rendered_html docutils container">
<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>atype</th>
      <th>pos[0]</th>
      <th>pos[1]</th>
      <th>pos[2]</th>
      <th>charge</th>
      <th>stress[0][0]</th>
      <th>stress[0][1]</th>
      <th>stress[0][2]</th>
      <th>stress[1][0]</th>
      <th>stress[1][1]</th>
      <th>stress[1][2]</th>
      <th>stress[2][0]</th>
      <th>stress[2][1]</th>
      <th>stress[2][2]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>0</td>
      <td>1</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>1.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>1.6</td>
      <td>1.6</td>
      <td>1.6</td>
      <td>-1.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
    </tr>
  </tbody>
</table>
</div></div>
</div>
<p>The advantage of using atomman.load(‘system_model’) is that it is designed to also handle larger data models that may contain embedded system model elements. Depending on what the larger data model represents, multiple system data models may be embedded as a list or differentiated by different root element keys. The key and index parameters of atomman.load(‘system_model’) therefore make it possible to uniquely select one system model from within a larger data model.</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[15]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre>
<span></span><span class="c1"># Define a larger data model</span>
<span class="n">collection_model</span> <span class="o">=</span> <span class="n">DM</span><span class="p">()</span>
<span class="n">collection_model</span><span class="p">[</span><span class="s1">&#39;system-collection&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">DM</span><span class="p">()</span>

<span class="c1"># Add multiple system models under the test-atomic-system key</span>
<span class="n">collection_model</span><span class="p">[</span><span class="s1">&#39;system-collection&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;test-atomic-system&#39;</span><span class="p">,</span> <span class="n">model</span><span class="p">[</span><span class="s1">&#39;atomic-system&#39;</span><span class="p">])</span>
<span class="n">collection_model</span><span class="p">[</span><span class="s1">&#39;system-collection&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;test-atomic-system&#39;</span><span class="p">,</span> <span class="n">model</span><span class="p">[</span><span class="s1">&#39;atomic-system&#39;</span><span class="p">])</span>

<span class="c1"># Use atomman.load() to load the second &#39;test-atomic-system&#39; model</span>
<span class="n">system3</span> <span class="o">=</span> <span class="n">am</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s1">&#39;system_model&#39;</span><span class="p">,</span> <span class="n">collection_model</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s1">&#39;test-atomic-system&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">system3</span><span class="p">)</span>
<span class="n">system3</span><span class="o">.</span><span class="n">atoms_df</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="nboutput docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
avect =  [ 3.200,  0.000,  0.000]
bvect =  [ 0.000,  3.200,  0.000]
cvect =  [ 0.000,  0.000,  3.200]
origin = [ 0.000,  0.000,  0.000]
natoms = 2
natypes = 2
symbols = (&#39;Cs&#39;, &#39;Cl&#39;)
pbc = [ True  True  True]
per-atom properties = [&#39;atype&#39;, &#39;pos&#39;, &#39;charge&#39;, &#39;stress&#39;]
     id |   atype |  pos[0] |  pos[1] |  pos[2]
      0 |       1 |   0.000 |   0.000 |   0.000
      1 |       2 |   1.600 |   1.600 |   1.600
</pre></div></div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[15]:
</pre></div>
</div>
<div class="output_area rendered_html docutils container">
<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>atype</th>
      <th>pos[0]</th>
      <th>pos[1]</th>
      <th>pos[2]</th>
      <th>charge</th>
      <th>stress[0][0]</th>
      <th>stress[0][1]</th>
      <th>stress[0][2]</th>
      <th>stress[1][0]</th>
      <th>stress[1][1]</th>
      <th>stress[1][2]</th>
      <th>stress[2][0]</th>
      <th>stress[2][1]</th>
      <th>stress[2][2]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>0</td>
      <td>1</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>1.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>1.6</td>
      <td>1.6</td>
      <td>1.6</td>
      <td>-1.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
      <td>0.0</td>
    </tr>
  </tbody>
</table>
</div></div>
</div>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Introduction to atomman: system_model conversions</a><ul>
<li><a class="reference internal" href="#1.-Introduction">1. Introduction</a><ul>
<li><a class="reference internal" href="#1.1.-Notes-on-the-system-model-format">1.1. Notes on the system model format</a></li>
</ul>
</li>
<li><a class="reference internal" href="#2.-Dump">2. Dump</a><ul>
<li><a class="reference internal" href="#2.1.-System.model()">2.1. System.model()</a><ul>
<li><a class="reference internal" href="#2.1.1.-Simple-example">2.1.1. Simple example</a></li>
<li><a class="reference internal" href="#2.1.2.-Specify-units-and/or-limit-included-properties">2.1.2. Specify units and/or limit included properties</a></li>
</ul>
</li>
<li><a class="reference internal" href="#2.2.-System.dump(‘system_model’)">2.2. System.dump(‘system_model’)</a><ul>
<li><a class="reference internal" href="#2.2.1.-Simple-example">2.2.1. Simple example</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#3.-Load">3. Load</a><ul>
<li><a class="reference internal" href="#3.1.-System.__init__(model)">3.1. System.__init__(model)</a></li>
<li><a class="reference internal" href="#3.2.-atomman.load(‘system_model’)">3.2. atomman.load(‘system_model’)</a><ul>
<li><a class="reference internal" href="#3.2.1.-Examples">3.2.1. Examples</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="1.4._Load_and_dump_conversions.html"
                        title="previous chapter">Introduction to atomman: Load and dump conversions</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="1.4.2._POSCAR_conversions.html"
                        title="next chapter">Introduction to atomman: POSCAR conversions</a></p>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="1.4.2._POSCAR_conversions.html" title="Introduction to atomman: POSCAR conversions"
             >next</a> |</li>
        <li class="right" >
          <a href="1.4._Load_and_dump_conversions.html" title="Introduction to atomman: Load and dump conversions"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">atomman 1.4.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >Tutorials</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.2.0.
    </div>
  </body>
</html>